import { callService } from "./api";
import type {
  OrderListParams,
  OrderListResponse,
  OrderSubmitPayload,
  OrderSubmitResponse,
  OrderAcceptPayload,
  OrderRejectPayload,
  OrderUpdateResponse,
  ReviewSubmitPayload,
  ReviewSubmitResponse,
} from "../types/dto";

export function fetchOrders(params: OrderListParams) {
  return callService<OrderListResponse>("ordersList", params as unknown as Record<string, unknown>);
}

export function submitOrder(payload: OrderSubmitPayload) {
  return callService<OrderSubmitResponse>("ordersSubmit", payload as unknown as Record<string, unknown>);
}

export function startCooking(orderId: string) {
  return callService<OrderUpdateResponse>("ordersStart", { orderId });
}

export function acceptOrder(payload: OrderAcceptPayload) {
  return callService<OrderUpdateResponse>("ordersAccept", payload as unknown as Record<string, unknown>);
}

export function rejectOrder(payload: OrderRejectPayload) {
  return callService<OrderUpdateResponse>("ordersReject", payload as unknown as Record<string, unknown>);
}

export function finishCooking(orderId: string) {
  return callService<OrderUpdateResponse>("ordersComplete", { orderId });
}

export function getOrderDetail(orderId: string) {
  return callService<OrderUpdateResponse>("ordersDetail", { orderId });
}

export function submitReview(payload: ReviewSubmitPayload) {
  return callService<ReviewSubmitResponse>("ordersReview", payload as unknown as Record<string, unknown>);
}
